/**
 * WebRTC 信令服务常量定义
 */

// Redis Key 前缀
export const REDIS_PREFIXES = {
  DEVICE: 'webrtc:device:',
  ROOM: 'webrtc:room:',
  CONN: 'webrtc:conn:',
  CALL: 'webrtc:call:'
}

// Redis 频道
export const REDIS_CHANNELS = {
  BROADCAST: 'webrtc:broadcast',
  RELAY: 'webrtc:relay'
}

// WebSocket 消息命令
export const WS_COMMANDS = {
  // 基础命令
  PING: 'cmd_ping',
  PONG: 'cmd_pong',
  LOGIN: 'cmd_login',
  
  // 房间相关
  JOIN_ROOM: 'cmd_join_room',
  START_CALL: 'cmd_start_call',
  HANG_UP: 'cmd_hang_up',
  STOP_ROOM: 'cmd_stop_room',
  
  // WebRTC 信令
  OFFER: 'cmd_offer',
  ANSWER: 'cmd_answer',
  ICE: 'cmd_ice',
  
  // 状态管理
  AV_STATUS: 'cmd_av_status',
  CURRENT_PEERS: 'cmd_current_peers',
  NEW_PEER: 'cmd_new_peer',
  PEER_JOIN: 'cmd_peer_join',
  PEER_LEAVE: 'cmd_peer_leave',
  
  // 错误处理
  ERROR: 'cmd_error',
  
  // 管理员命令
  ADMIN_BROADCAST: 'cmd_admin_broadcast',
  ADMIN_KICK: 'cmd_admin_kick'
}

// WebSocket 连接状态
export const WS_CONNECTION_STATES = {
  CONNECTING: 0,
  OPEN: 1,
  CLOSING: 2,
  CLOSED: 3
}

// 心跳配置
export const HEARTBEAT_CONFIG = {
  INTERVAL_MS: 25000,
  TIMEOUT_MS: 30000
}

// 错误类型
export const ERROR_TYPES = {
  OFFLINE: 'offline',
  IN_CALL: 'inCall',
  INVALID_URL: 'invalid_url',
  DUPLICATE_CONNECTION: 'duplicate_connection'
}

// 连接关闭代码
export const CLOSE_CODES = {
  NORMAL: 1000,
  INVALID_URL: 1000,
  DUPLICATE_CONNECTION: 4000
}
